package com.elong.businesstravel.protocol.hotel;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONObject;

import com.elong.businesstravel.entitys.HotelNameSearchResult;
import com.elong.businesstravel.protocol.baseresponse.BaseELongJsonHttpResponse;

public class AllInOneSearchResponse extends BaseELongJsonHttpResponse {
	
	public List<HotelNameSearchResult> hotelNameSearchResults = new ArrayList<HotelNameSearchResult>();

	@Override
	public void onSuccess(int statusCode, Header[] headers,
			JSONObject mainJsonObject) throws Throwable {
		JSONArray responseJsonArray = mainJsonObject.getJSONArray("response");
		for (int i = 0; i < responseJsonArray.length(); i++) {
			HotelNameSearchResult hotelNameSearchResult = new HotelNameSearchResult();
			JSONObject itemJsonObject = responseJsonArray.getJSONObject(i);
			
			hotelNameSearchResult.bussinename = itemJsonObject.optString("bussinename", "");
			hotelNameSearchResult.bussinesid = itemJsonObject.optString("bussinesid", "");
			hotelNameSearchResult.hotelName = itemJsonObject.optString("hotelName", "");
			hotelNameSearchResult.hotelid = itemJsonObject.optString("hotelid", "");
			hotelNameSearchResult.poiid = itemJsonObject.optString("poiid", "");
			hotelNameSearchResult.name = itemJsonObject.optString("name", "");
			hotelNameSearchResult.googlelat = itemJsonObject.optString("googlelat", "");
			hotelNameSearchResult.line = itemJsonObject.optString("line", "");
			hotelNameSearchResult.googlelng = itemJsonObject.optString("googlelng", "");
			hotelNameSearchResult.id = itemJsonObject.optString("id", "");
			hotelNameSearchResult.districtsid = itemJsonObject.optString("districtsid", "");
			hotelNameSearchResult.districtsname = itemJsonObject.optString("districtsname", "");
			hotelNameSearchResult.sorts = itemJsonObject.optString("sorts", "");
			hotelNameSearchResult.cityid = itemJsonObject.optString("cityid", "");
			hotelNameSearchResult.precount = itemJsonObject.optString("precount", "");
			hotelNameSearchResult.hotelcount = itemJsonObject.optString("hotelcount", "");
			hotelNameSearchResult.typeid = itemJsonObject.optString("typeid", "");
			hotelNameSearchResult.shortname = itemJsonObject.optString("shortname", "");
			hotelNameSearchResult.brandid = itemJsonObject.optString("brandid", "");
			hotelNameSearchResult.type = itemJsonObject.optString("type", "");
			hotelNameSearchResult.letters = itemJsonObject.optString("letters", "");
			
			hotelNameSearchResults.add(hotelNameSearchResult);
		}
	}

}
